ABC291 D - Flip Cards
https://atcoder.jp/contests/abc291/tasks/abc291_d
提出
WA
code: python
n = int(input())
ab = list(map(int, input().split())) for _ in range(n)
# pow(2, pow(10, 5))
# 両隣だけが問題
ans = 0
for i in range(n-1):
m = len(set(abi) - set(abi+1))
if m == 0:
continue
elif m == 1:
ans += 1
else:
if ans == 0:
ans = 2
else:
ans *= 2
print(ans * 2)
解答
code: python
n = int(input())
ab = list(map(int,input().split())) for _ in range(n)
mod = 998244353
# dpiflag= i枚目のカードまでの表裏の決め方のうち、条件を満たし、i枚目のカードが(flag ? 表 : 裏)であるような方法の数
dp = [0, 0 for _ in range(n)]
dp0 = 1, 1
for i in range(1, n):
for pre in range(2):
for nxt in range(2):
# 番号が異なれば
if abi-1pre != abinxt:
dpinxt += dpi-1pre % mod
print((dpn-10 + dpn-11) % mod)
テーマ
#dp
メモ
https://atcoder.jp/contests/abc291/editorial/5838
https://scrapbox.io/files/65cf23c6c80363002495ac28.png
提出
code: python
n = int(input())
ab = list(map(int, input().split())) for _ in range(n)
# print(ab)
# 1, 2], 4, 2, [3, 4
mod = 998244353
same1 = 0
same2 = 0
for i in range(n-1):
a1, b1 = abi
a2, b2 = abi+1
if (a1 == a2 and b1 == b2) or (a1 == b2 and b1 == a2):
same2 += 1
elif (a1 == a2) or (b1 == b2) or (a1 == b2) or (b1 == a2):
same1 += 1
print(same1, same2)
print(pow(2, 8) - pow(2,4)*2 - pow(2,2)*8*2)